package com.project.config;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())//注册拦截器
                .addPathPatterns("/index.html")
                .addPathPatterns("/class.html")
                .addPathPatterns("/room.html")
                .addPathPatterns("/student.html")
                .addPathPatterns("/change.html")
                .addPathPatterns("/user.html");//定义拦截器范围
    }

    /**
     * 图片映射路径部署在tomcat容器中
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/studentface/**")
                .addResourceLocations("file:/Users/cengyunke/Desktop/studen/src/main/resources/static/studentface/");
    }
}
